<?php
  $page=NULL;

  function open_page($title, $description, $keywords, $authed)
  {
   global $page;

   $page = new Page($title, $description, $keywords, $authed);
   $page->open();

   return $page; 
  }
  
  function close_page()
  {
   global $page;

   if ($page==NULL)
       return;


   $page->close();
   $page=NULL;
  }

  function get_page()
  {
    global $page;
    return $page;
  } 
   
  class Page
  {
   private $_title;
   private $_description;
   private $_keywords;
   private $_authed;
   
   function __construct($title, $description, $keywords, $authed)
   {
     $this->_title = $title;
     $this->_description = $description;
     $this->_keywords = $keywords;
	 $this->_authed = $authed;
   }
	   
   public function open()
   {
     echo "<!DOCTYPE HTML>\n";
     echo "<html>\n";
     echo "<head>\n";
     echo "<title>".$this->_keywords." - ".$this->_title."</title>\n";
	 echo "<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>\n";
     echo "<meta name='description' content=''.$this->_description.''>\n";
     echo "<meta name='keywords' content=''.$this->_keywords.''>\n";
     echo "<link rel='stylesheet' href='styles.css' type='text/css'>\n";
	if ($this->_keywords == "Log in" || $this->_keywords == "Sign up")
	{
	   echo "<link href='./img/origin/favicon.ico' rel='shortcut icon' type='image/x-icon'>\n";
	}
	else
	{
		echo "<link href='./img/favicon.ico' rel='shortcut icon' type='image/x-icon'>\n";
	}
	 echo "<LINK href='css/battlelog.css' rel='stylesheet' type='text/css'>\n";
	 echo "<LINK href='css/bf4-static.css' rel='stylesheet' type='text/css'>\n";
	 echo "<LINK href='css/bf4.css' rel='stylesheet' type='text/css'>\n";
	 echo "<LINK href='css/origin.css' rel='stylesheet' type='text/css'>\n";
	 echo "<link rel='stylesheet' href='./css/alert.css'>\n";
	 echo "<link rel='stylesheet' href='./css/input.css'>\n";
	 echo "<link rel='stylesheet' href='./css/leaderboard.css'>\n";
	 echo "<link rel='stylesheet' href='./css/nav.css'>\n";
	 echo "<link rel='stylesheet' href='./css/profile.css'>\n";
	 echo "<LINK href='./css/serverbrowser.css' rel='stylesheet' type='text/css'>\n";
	 echo "<link rel='stylesheet' href='./css/tablesorter.css'>\n";
	 echo "<link rel='stylesheet' href='./css/comcenter.css'>\n";
	 echo "<link rel='stylesheet' href='./css/login.css'>\n";
	 echo "<link rel='stylesheet' href='./css/awards.css'>\n";
	 echo "<script src='./js/jquery-2.0.3.min.js'></script>\n";
	 echo "<script src='./js/bootstrap.min.js'></script>\n";
     echo "<script src='./js/ajax-form.js'></script>\n";
	 echo "<script type='text/javascript' src='js/ajaxupload.3.5.js'></script>\n";
	 echo "<script src='./js/script.js'></script>\n";
	 //echo "<script src='./js/savedogtagsbar.js'></script>\n";
	 
	 	 
     echo "</head>\n";
	if ($this->_authed == true)
	{
		echo "<body id='body' class='no-comcenter is-loggedin premium'>\n";
		//echo "<body class='is-loggedin premium'>\n";
		//include("includes/comcenter.php");
	}
	else
	{
		echo "<body class='no-comcenter is-loggedout'>\n";
	}
	include("./pages/languageSelect.php");
	
   } 
       
   public function close()
   {
	 //echo "<script src='./js/jquery-2.0.3.min.js'></script>\n";
	 //echo "<script src='./js/ajax-form.js'></script>\n";
	 echo "</body>\n";
     echo "</html>\n";
   }

   public function get_keyword()
   {
     return $this->_keywords;
   } 
   
   public function begin_header()
   {
     echo "<HEADER id='base-header'>";
   } 
   
   			
   public function end_header()
   {
     echo "</HEADER>";
	 
   } 

   public function begin_center($lang)
   {
    echo "<DIV id='base-background'>\n";
	echo "<DIV class='video-container show'>\n";
	
	
	/*echo "<video id='background-video' autoplay='' loop='' name='media' preload='auto'>
	<source media='screen' src='./video/bg-video.webm' type='video/webm'>
	<source media='screen' src='./video/bg-video.ogg' type='video/ogg'>
	<source media='screen' src='./video/bg-video.mp4' type='video/mp4'>
	</video>\n";*/
	
	
	/*echo "<video id='background-video' autoplay='' loop='' name='media' preload='auto'>
	<source media='screen' src='./video/rainbackgroundloop.webm' type='video/webm'>
	<source media='screen' src='./video/rainbackgroundloop.ogg' type='video/ogg'>
	<source media='screen' src='./video/rainbackgroundloop.mp4' type='video/mp4'>
	</video>\n";
	
	
	/*echo "<video id='background-video' autoplay='' loop='' name='media' preload='auto'>
	<source media='screen' src='./video/last-stand.webm' type='video/webm'>
	<source media='screen' src='./video/last-stand.ogg' type='video/ogg'>
	<source media='screen' src='./video/last-stand.mp4' type='video/mp4'>
	</video>\n";*/
	
	
	echo "</DIV>\n";
	echo "</DIV>\n";
	 
	 
	if ($this->_authed == true)
	{
		require_once "./includes/header.php";
	}
	else
	{
		require_once "./includes/header1.php";
	}
 
	 echo "<DIV id='viewport'>\n";
     echo "<DIV id='base-page'>\n";
     echo "<DIV class='grid-container' id='base-container'>\n";
	 
	 /*
	 if ($this->_authed == false)
	{
		echo "<div>";
		echo "<img width='300px' src='./img/logo.png' style='display: block; margin-left: auto; margin-right: auto; cursor: pointer;margin-top: -75px;'>";
		echo "</div>";
	}
 	 */
	 echo "<DIV class='content' id='content'>\n";
	 echo "<SECTION class='grid-container' id='game-stats'>\n";
		
   }

   public function end_center()
   {
    echo "</SECTION>\n";
    echo "</DIV>\n";
	echo "</DIV>\n";
	echo "</DIV>\n";
	echo "</DIV>\n";
   }

   public function begin_footer()
   {
     echo "<div class='footer'>\n";
   } 

   public function end_footer()
   {
     echo "</div>\n";
	 
   } 
  }
?>